home *** CD-ROM | disk | FTP | other *** search
/ Action Games (2008) / akcnihry1.iso / AT-Robots 2.10 / SNIPER2.AT2 < prev    next >
Encoding:
Text File  |  1999-04-27  |  5.5 KB  |  175 lines

  1. ; Sniper 2.  4/21/99.    Copyright 1999 Ed T. Toton III, All Rights Reserved.
  2. ;
  3. ; This is a new version of sniper, written from scratch. It's a little
  4. ; smarter, but is still intended to be only an example and not a high-
  5. ; powered contestant for the tournaments.
  6. ;
  7. ; Notice there are few or no hard JMP commands. Whenever you see a
  8. ; je/jne to the same label together, it acts like a hard jmp but requires
  9. ; zero cpu cycles to execute.
  10.  
  11. #msg You can't hide!
  12.  
  13. #config scanner=4   ; Saves a point
  14. #config armor=3     ; Consumes a point
  15. ;#config engine=1    ; Saves a point
  16. ;#config heatsinks=2 ; Consumes a point
  17.  
  18. #def turret_home
  19. #def arc
  20. #def armor
  21. #def firecode
  22.  
  23. !start
  24.  
  25.  
  26.  
  27. ;------------ Goto a random wall.---------------
  28.  
  29.         ipo     10      ax      ; Get random number
  30.         and     ax      3       ; now it's 0-3
  31.         add     ax      1000    ; routine 1000-1003
  32.         jmp     ax
  33.  
  34. :1000
  35.         mov     ex      500
  36.         mov     fx      0
  37.         mov     turret_home     080h
  38.         je      1004
  39.         jne     1004
  40. :1001
  41.         mov     ex      1000
  42.         mov     fx      500
  43.         mov     turret_home     0C0h
  44.         je      1004
  45.         jne     1004
  46. :1002
  47.         mov     ex      500
  48.         mov     fx      1000
  49.         mov     turret_home     000h
  50.         je      1004
  51.         jne     1004
  52. :1003
  53.         mov     ex      0
  54.         mov     fx      500
  55.         mov     turret_home     040h
  56. :1004
  57.         int     7
  58.         call    !set-course     ; set course
  59. :1005
  60.         ipo     3       ax      ; Check our heading
  61.         cmp     ax      @1      ; Compare to our desired heading.
  62.         jne     1005            ; Wait for turn to complete
  63.  
  64.         opo     11      100     ; And start driving
  65.         mov     ax      1       ; ax = 1
  66.         int     4               ; overburn = on
  67.         opo     13      0       ; aim turret straight ahead.
  68.  
  69. :1006
  70.         ipo     2       ax      ; Check heat
  71.         cmp     ax      0       ; is it 0?
  72.         jne     1007            ; if not, then skip next line
  73.         opo     15              ; Fire!
  74. :1007
  75.         cmp     @0      0       ; Is our throttle set back to 0?
  76.         jne     1006            ; If not, keep checking.
  77.  
  78.         mov     ax      turret_home
  79.         call    !set-course     ; Aim away from wall.
  80.         xor     ax      ax      ; ax = 0
  81.         int     4               ; overburn = off
  82.         ipo     6       armor   ; Get our armor level
  83. :1008
  84.         ipo     3       ax      ; Check our heading
  85.         cmp     ax      @1      ; Compare to our desired heading.
  86.         jne     1008            ; Wait for turn to complete
  87.  
  88.  
  89.  
  90. ;----------Now look for enemy to kill----------
  91. !scan
  92.         mov     arc     64      ; Set our inital scan arc
  93.         mov     ax      turret_home
  94.         sub     ax      @1
  95.         opo     13      ax      ; Set turret to aim at home-position
  96.  
  97. ; Begin the actual scan
  98. :2000
  99.         opo     17      arc     ; Set scan-arc
  100.         ipo     7       ax      ; Scan for enemy
  101.         cmp     ax      2000
  102.         ja      !decide         ; If no one there, decide what to do.
  103.  
  104.         mov     ax      @3      ; Get accuracy
  105.         add     ax      2012    ; move it to 2010-2014 range
  106.         je      ax
  107.         jne     ax
  108.  
  109. :2010
  110.         xor     ax      ax      ; ax = 0
  111.         sub     ax      arc     ; ax = 0-arc
  112.         opo     12      ax      ; turn turret left
  113.     mov    firecode -2    
  114.         je      2015
  115.         jne     2015
  116. :2011
  117.         xor     ax      ax      ; ax = 0
  118.         sub     ax      arc     ; ax = 0-arc
  119.         sar     ax      1       ; ax = (0-arc)/2
  120.         opo     12      ax      ; turn turret left
  121.     mov    firecode -1    
  122.         je      2015
  123.         jne     2015
  124. :2012
  125.         ipo     2       ax       ; Check heat
  126.         cmp     ax      150      ; Campare to 150
  127.         ja      2015             ; If too hot, skip shooting
  128.         opo     15      firecode ; Fire!
  129.     mov    firecode 0
  130.         je      2015
  131.         jne     2015
  132. :2013
  133.         mov     ax      arc     ; ax = arc
  134.         shr     ax      1       ; ax = arc/2
  135.         opo     12      ax      ; turn turret right
  136.     mov    firecode 1    
  137.         je      2015
  138.         jne     2015
  139. :2014
  140.         mov     ax      arc     ; ax = arc
  141.         opo     12      ax      ; turn turret right
  142.     mov    firecode 2    
  143.         je      2015
  144.         jne     2015
  145. :2015
  146.         cmp     arc     2       ; compare arc to 2
  147.         jle     2000            ; If arc <= 2, then skip shrinking it.
  148.         shr     arc     2       ; cut our arc to 1/4 size
  149.         je      2000            ; Scan again.
  150.         jne     2000
  151.  
  152.  
  153. !decide
  154.         cmp     arc     64      ; What is our arc setting?
  155.         jae     !start          ; If too wide, move to another wall.
  156.         ipo     6       ax      ; Check armor
  157.         cmp     ax      armor   ; Did we get damaged?
  158.         jne     !start          ; If damaged, move to another wall.
  159.         shl     arc     1       ; Otherwise widen the arc, repeat scan.
  160.         je      2000
  161.         jne     2000
  162.  
  163. ;-------------------------------------------------------------------------
  164.  
  165. ;set course to heading in AX.
  166. !set-course
  167.         mov     bx,     @1      ; get current desired heading
  168.                                 ; (not actual heading)
  169.         and     ax,     255     ; Fix ax into 0-255.
  170.         sub     ax,     bx      ; get number of degrees to turn.
  171.         opo     14,     ax      ; turn!
  172.         ret                     ; All done!
  173.  
  174.  
  175.